#pragma once

class CSqliteReader : public IReader
{
public:
	CSqliteReader();
	~CSqliteReader();

	bool	read()												;
	bool	getint(int index,int& ret)							;
	bool	getint64(int index,long long& ret)					;
	bool	getdouble(int index,double& ret)					;
	bool	getwstring(int index,wchar_t* ret,int& iLen)		;
	bool	getcolname(int index,wchar_t* ret,int& iLen)		;
	bool	release()											;

	bool	SetReader(sqlite3_connection& con,const wchar_t* chSql);
private:
	sqlite3_command*	m_pCmd;
	sqlite3_reader*		m_pReader;
};

class CSqliteexec2 : public ISqliteexec2
{
public:
	CSqliteexec2(void);
	~CSqliteexec2(void);

	bool	initsqlitedb	 (const wchar_t* szDbPath)				;
	bool	sqlitekey		 (const wchar_t* chPwd)					;
	bool	sqliterekey		 (const wchar_t* chPwd)					;
	bool	sqlitesqlRv		 (const wchar_t* chSql)					;
	bool	sqlitesqlRi		 (const wchar_t* chSql,int& ret)		;
	bool	sqlitesqlRdbl	 (const wchar_t* chSql,double& ret)		;
	bool	sqlitesqlRwc	 (const wchar_t* chSql,wchar_t* ret,int& iLen)	;
	IReader*	sqlitesqlRIReader(const wchar_t* chSql)				;
	bool	sqlitesetbusytimeout(int ms)							;
	bool	release()												;
private:
	sqlite3_connection	m_sqlCon;
};
